//
//  BN_PinglunCell.m
//  BabyNow
//
//  Created by 刘泽琛 on 14-4-1.
//  Copyright (c) 2014年 iMobile. All rights reserved.
//

#import "BN_PinglunCell.h"

@implementation BN_PinglunCell

- (void)awakeFromNib
{
    // 用户头像圆形
    UIImage * image = [UIImage imageNamed:@"cool.jpg"];  // 设置原图
    CGSize size = CGSizeMake(300,300);  // 设置尺寸
    self.userPhoto.image = [UIImage createRoundedRectImage:image size:size radius:150];   // 设置radius
    // 用户名称
    self.userName.font = [UIFont fontWithName:@"TrebuchetMS-Bold" size:14];
}

- (void)changeRowHeight {
    
    self.userContent.numberOfLines = 0;
    UIFont * tfont = [UIFont systemFontOfSize:14.0f];
    self.userContent.font = tfont;
    self.userContent.lineBreakMode = NSLineBreakByCharWrapping ;
    CGSize size =CGSizeMake(240,10000);
    NSDictionary * tdic = [NSDictionary dictionaryWithObjectsAndKeys:tfont,NSFontAttributeName,nil];
    
    switch (MAIN_VERSION) {
        case 6:
        {
            CGSize iOS6size = [self.userContent.text  sizeWithFont:[UIFont systemFontOfSize:14.0f] constrainedToSize:size lineBreakMode:NSLineBreakByWordWrapping];
            self.userContent.frame = CGRectMake(64, 31, 244, iOS6size.height);
            [self.userContent sizeToFit];
            self.cellHeight = CGRectGetMaxY(self.userContent.frame)+12;
        }
            break;
        default:
        {
            CGSize actualsize =[self.userContent.text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin |NSStringDrawingUsesFontLeading attributes:tdic context:nil].size;
            self.userContent.frame = CGRectMake(64, 31, 244, actualsize.height);
            [self.userContent sizeToFit];
            self.cellHeight = CGRectGetMaxY(self.userContent.frame)+12;
        }
            break;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

}

@end
